<?php

namespace App\Http\Controllers\Api;

use Hprose\Client;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use SimpleSoftwareIO\QrCode\Facades\QrCode;
/**
     * @SWG\Get(
     *   path="/home",
     *   summary="用户资料",
     *   @SWG\Response(response=200, description="请求成功"),
     *   @SWG\Response(response=401, description="用户验证失败"),
     *   @SWG\Response(response=500, description="服务器错误")
     * )
     *
     */
class QrcodeController extends Controller
{

    public function index(){
        //在文件夹生成svg二维码
        if(!file_exists('public/qrcodes/')){
            //dd(file_exists('public/qrcodes'));
           // dd($_SERVER['DOCUMENT_ROOT'].'/qrcodes');
            //mkdir('/public/qrcodes/');
        }
        dd($_SERVER['DOCUMENT_ROOT']);
        QrCode::format('png')->size(300)->backgroundColor(255,255,0)->generate('Make me into a QrCode!',$_SERVER['DOCUMENT_ROOT'].'/qrcodes/qrcode.png');;

        //return  QrCode::size(100)->generate('Make me into a QrCode!');
        $to='1105730947@qq.com';
        $subject='568204083@qq.com';
        $body='lai djsl lid iuy kme';
       // return QrCode::size(400)->email($to, $subject, $body);
       return QrCode::size(100)->wiFi([
            'encryption' => 'WPA/WEP',
            'ssid' => 'MSG',
            'password' => ''
        ]);
    }

    //关于hprose客户端调用运城rpc所制作的函数
    public function getHproseRpc(){
        $client=Client::create('tcp://127.0.0.1:1314',false);
//        $client->getUserByName('xiaoming')->then(function($result){
//            dd($result);
//        });
        $object=$client->getUserByName('xiaoming');
        $demo=$client->demo();
        dd($demo);
        //echo '12345678';
        //$client=new Client('tcp://0.0.0.0:1314');
        //echo $client->getUserByName('xiaoming');
       // dd($client->getUserByName('xiaoming'));
    }

    //测试状态码
    public function testStatus(){
        $data=[];
        return response()->json($data,201,[],JSON_NUMERIC_CHECK);
    }
}
